/**
 * Created by YangYan on 2016/5/23.
 */
(function () {
    function typeAndValue(x) {
        if(x == null) return "";
        switch (x.constructor){
            case Number:return "Number:"+x;
            case String:return "String:'"+ x+"'";
            case Date:return "Date:"+x;
            case RegExp:return "Regexp:"+x;
            case Complex:return "Complex:"+x;
        }
    };
    var s=34;
    console.log(s.constructor);
    var s1="123";
    console.log(s1.constructor);
    typeAndValue(s);
    //----------------------------------------------------

    function type(o){
        var t,c,n;
        if(o !== null) return "null";
        if(o !==o) return "nan";
        if((t=typeof o)!=="Object") return t;
        if(o.constructor && typeof o.constructor ==="function" && (n=o.constructor.getName())) return n;
        return "Object";
    };
    function classof(o){
        return Object.prototype.toString.call(o).slice(8,-1);
    };
    Function.prototype.getName=function(){
        if("name" in this) return this.name;
        return this.name=this.toString().match(/function\s*([^(]*)\(/)[1];
    };
    var Complex=function(x,y){this.r=x;this.i=y;};//这个构造函数没有名称
    var Range=function Range(f,t){this.from=f;this.to=t;};//这个构造函数有名称
    

})()
